package com.mazsn.single;

/**
 * 双检锁/双重校验锁 模式实现单例模式
 * 
 * @author mazhongshan
 * volatile 定义的变量当变量值变化时，会通知所有使用该变量的线程，使用改变后的值 
 */
public class Singleton3 {
	
		private volatile static Singleton3 singleton;  
		
	    private Singleton3 (){}  
	    
	    public static Singleton3 getInstance() {  
	    if (singleton == null) {  
	        synchronized (Singleton3.class) {  
		        if (singleton == null) {  
		            singleton = new Singleton3();  
		        }  
	        }  
	    }  
	    return singleton;  
    }  
}
